import employeesData from '@/api/constant/employees'
import Store from '@/store'
export default {
  imgerror: {
    // 图片错误时处理
    inserted(dom, obj) {
      dom.src = dom.src || obj.value
      dom.onerror = function() {
        dom.src = obj.value
      }
    },
    componentUpdated(dom, obj) {
      dom.src = dom.src || obj.value
    },
    unbind(dom) {
      dom.onerror = null
    }
  },
  // 是否转正
  formatterFormof: {
    inserted(dom, obj) {
      const temp = employeesData.hireType.find((item) => {
        return item.id === +obj.value
      })
      dom.innerText = temp ? temp.value : '-'
    },
    componentUpdated(dom, obj) {
      const temp = employeesData.hireType.find((item) => {
        return item.id === +obj.value
      })
      dom.innerText = temp ? temp.value : '-'
    }
  },
  // 按钮显示与隐藏
  visibleButton: {
    inserted(dom, obj) {
      if (!Store.state.user.userInfo.roles.points.includes(obj.value)) {
        dom.style.display = 'none'
      }
    },
    componentUpdated(dom, obj) {
      if (!Store.state.user.userInfo.roles.points.includes(obj.value)) {
        dom.style.display = 'none'
      }
    }
  }
}
